package com.example.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @program: backed
 * @author: zk
 * @create: 2023-03-23 19:13
 **/

@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("返回信息")
public class Result {
    @ApiModelProperty("状态")
    private int status;
    @ApiModelProperty("错误信息")
    private String msg;
    @ApiModelProperty("返回数据")
    private Object data;

    public static Result ok() {
        return new Result(0, null, null);
    }

    public static Result ok(Object data) {
        return new Result(0, null, data);
    }

    public static Result fail(String errorMsg) {
        return new Result(1, errorMsg, null);
    }

    public static Result fail(int status, String errorMsg) {
        return new Result(status, errorMsg, null);
    }
}
